import { Select } from 'antd';

import { getChannelApi } from 'api/getChannel';
import { useEffect, useState } from 'react';
const { Option } = Select;

export default function Channel(props) {
  const loadChannels = async () => {
    const res = await getChannelApi();
    console.log('res  ----->  ', res);
    setChannelList(res.data.channels);
  };
  const [channelList, setChannelList] = useState([]);
  useEffect(() => {
    loadChannels();
  }, []);
  return (
    <Select {...props} style={{ width: 200 }}>
      {channelList.map((item) => (
        <Option key={item.id} value={item.id}>
          {item.name}
        </Option>
      ))}
    </Select>
  );
}
